<template>
	<view>
		<designerHeader :message='message' :personalUserId='userId' :isIndex='true'/>	
		<view class="body">
			<view class="item" v-for="(item,index) in list" :key='index' @tap="toLink" :data-index='index'>
				<view class="item_left">
					<image :src="item.img" mode=""></image>
					<text>{{item.text}}</text>
				</view>
				<view class="item_right">
					<text>{{item.rightText}}</text>
					<image src="/static/svg/moreandmore.svg" mode=""></image>
				</view>
			</view>
		</view>
		<view style="height:88rpx"></view>
		<indexFooter :active="3"/>
	</view>
</template>

<script>
	import url from '@/common/util/personal.js'
	import designerHeader from "@/components/otherHomepage/designerHeader.vue"
	import indexFooter from "@/components/footer/footer.vue"
	export default {
		components: {designerHeader,indexFooter},
		data() {
			return {
				userId:localStorage.getItem("userId"),
				message:{},
				list:[{
					img:"/static/svg/sjsrz.svg",
					text:"设计师入驻",
					rightText:"已认证",
					link:"/pages/personal/designerSettledIn"
				},
				{
					img:"/static/svg/sjszp.svg",
					text:"设计作品",
					rightText:"",
					link:"/pages/personal/myHomeDesign"
				},
				{
					img:"/static/svg/ysjp.svg",
					text:"艺术精品",
					rightText:"",
					link:"/pages/personal/myFineArts"
				},
				{
					img:"/static/svg/wcyd.svg",
					text:"我参与的",
					rightText:"收藏/评论/点赞/分享",
					link:"/pages/personal/myPartake"
				},{
					img:"/static/svg/cgx.svg",
					text:"草稿箱",
					rightText:"",
					link:"/pages/personal/draftBox"
				},
				{
					img:"/static/svg/sjhz.svg",
					text:"商家合作",
					rightText:"",
					link:"/pages/personal/storeTogether"
				},
				{
					img:"/static/svg/wddd.svg",
					text:"我的订单",
					rightText:"",
					link:"/pages/order/order"
				},
				{
					img:"/static/svg/spsc.svg",
					text:"商品收藏",
					rightText:"",
					link:"/pages/user/collect"
				},
				{
					img:"/static/svg/wdpl.svg",
					text:"我的评价",
					rightText:"",
					link:"/pages/comment/myComment"
				},
				{
					img:"/static/svg/wdzj.svg",
					text:"我的足迹",
					rightText:"",
					link:"/pages/user/footprint"
				},
				{
					img:"/static/svg/shfw.svg",
					text:"售后服务",
					rightText:"",
					link:"/pages/order/marketServer"
				},
				{
					img:"/static/svg/yhj.svg",
					text:"优惠券",
					rightText:"",
					link:"/pages/coupon/coupon"
				}]
			};
		},
		onShow() {
			this.getMessage()
		},
		methods:{
			async getMessage(){
				let res=await url.getHome({userId:this.userId,selfId:this.userId})
				this.message=res.data
				if(res.data.userType!='设计师'){
					uni.redirectTo({
						url: '/pages/personal/plainUser'
					})
				}
				if(this.message.isSuccess=='Y'){
					this.list[0].rightText='已认证'
				}else if(this.message.isSuccess=='N'){
					this.list[0].rightText='审核未通过'
				}else if(this.message.isSuccess=='Z'){
					this.list[0].rightText='审核中'
				}
			},
			toLink(e){
				let index=e.currentTarget.dataset.index
				if(index==0){
					if(this.message.isFrist=='Y'){
						uni.navigateTo({
							url: this.list[index].link+'?type=isFrist&isFrom=designer'
						})
					}else if(this.message.isSuccess=='Y'){
						uni.navigateTo({
							url: this.list[index].link+'?type=isReady&isFrom=designer'
						})
					}else if(this.message.isSuccess=='N'){
						uni.navigateTo({
							url: this.list[index].link+'?type=isError&isFrom=designer'
						})
					}else if(this.message.isSuccess=='Z'){
						uni.navigateTo({
							url: this.list[index].link+'?type=isLoading'
						})
					}
					return
				}
				if(this.list[index].link){
					uni.navigateTo({
						url: this.list[index].link
					})
				}
			}
		}
		
	}
</script>

<style lang="scss">
.body{
	padding-left: 30rpx;
	.item{
		height: 140rpx;
		border-bottom: 1rpx solid #DDDDDD;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-right:30rpx ;
		.item_left{
			height: 100%;
			display: flex;
			align-items: center;
			image{
				height:60rpx ;
				width: 60rpx;
			}
			text{
				display: block;
				font-size: 30rpx;
				color:#333333 ;
				line-height: 30rpx;
				margin-left: 15rpx;
			}
		}
		.item_right{
			display: flex;
			justify-content: flex-end;
			align-items: center;
			height: 100%;
			image{
				height: 24rpx;
				width: 24rpx;
			}
			text{
				display: block;
				font-size: 30rpx;
				color:#AAAAAA ;
				line-height: 30rpx;
				margin-right: 10rpx;
			}
		}
	}
}
.body>view:last-of-type{
	border: 0;
}
</style>
